    /**
     * Created by ndh on 2019/4/20.
     */
    var curWwwPath = window.document.location.href;
    //获取主机地址之后的目录，如： /ems/Pages/Basic/Person.jsp
    var pathName = window.document.location.pathname;
    var pos = curWwwPath.indexOf(pathName);
    var treatyL = curWwwPath.indexOf("//");
    //获取主机地址，如： http://localhost:8080
    var localhostPath = curWwwPath.substring(treatyL, pos);

    var websocket = null;
    if ('WebSocket' in window) {
        websocket = new WebSocket("ws:"+localhostPath+"/websocket/socketServer.do");
    }
    else if ('MozWebSocket' in window) {
        websocket = new MozWebSocket("ws:"+localhostPath+"/websocket/socketServer.do");
    }
    else {
        websocket = new SockJS("http:"+localhostPath+"/sockjs/socketServer.do");
    }
    websocket.onopen = onOpen;
    websocket.onmessage = onMessage;
    websocket.onerror = onError;
    websocket.onclose = onClose;

    function onOpen(openEvt) {
        console.log(openEvt.Data);
    }
    function onError() {}
    function onClose() {}

    function doSend() {
        if (websocket.readyState == websocket.OPEN) {
            var msg = document.getElementById("inputMsg").value;
            websocket.send(msg);//调用后台handleTextMessage方法
            console.log("发送成功!");
        } else {
            console.log("连接失败!");
        }
    }
    window.close=function()
    {
        websocket.onclose();
    }
    $.messager.singleton={};
    $.messager.singleton.show=function(m){
        if(m){
            var divObj=$("div[class='messager-body panel-body panel-body-noborder window-body']");
            if(divObj.length){
                $(".messager-body").window('close');
            }
            $.messager.show({
                title:'我的消息',
                msg:m,
                timeout:0,
                showType:'slide',
                height:'auto'
            });
        }
    }
    function onMessage(evt) {
        // console.log(evt.data);
        var valHtml = bindClose(evt.data);
        $(".messager-body").window('close');
        $.messager.show({
            title:'我的消息',
            msg:valHtml,
            timeout:0,
            showType:'slide',
            height:'auto'
        });
    }
    function bindClose(valHtml) {
        var arrS;
        if(valHtml.indexOf("javascript:") > -1){
            arrS = valHtml.split("javascript:");
            valHtml = arrS[0]+"javascript:closeTips(),"+arrS[1];
        }
        if(valHtml.indexOf("onclick=") > -1){
            arrS = valHtml.split("onclick=");
            valHtml = arrS[0]+"onclick=closeTips(),"+arrS[1];
        }
        return valHtml;
    }
    function closeTips() {
        $(".panel-tool-close").click();
    }